package com.cuit.eduservice.controller;


import com.cuit.eduservice.entity.EduSubject;
import com.cuit.eduservice.entity.subject.OneSubject;
import com.cuit.eduservice.service.EduSubjectService;
import com.cuit.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * <p>
 * 课程科目 前端控制器
 * </p>
 *
 * @author horizon
 * @since 2020-09-16
 */
@RestController
@RequestMapping("/eduService/subject")
@CrossOrigin
public class EduSubjectController {

    @Autowired
    private EduSubjectService subjectService;

    //获取上传文件，把内容读取出来
    @PostMapping("/addSubject")
    public R addSubject(MultipartFile file){
        //上传excel文件
        subjectService.saveSubject(file,subjectService);
        return R.ok();
    }

    //树性
    @GetMapping("/findAllSubject")
    public R findAllSubject(){
        List<OneSubject> list = subjectService.findAllSubject();
        return R.ok().data("list",list);
    }

}

